Skip to content

Instantly share code, notes, and snippets.

View bdw's full-sized avatar
💭
Hacking

Bart Wiegmans bdw

💭
Hacking
View GitHub Profile
This file has been truncated, but you can view the full file.
Specialization of '' (cuid: 1)
Before:
Spesh of '' (cuid: 1, file: ./t/spec/S32-str/sprintf-b.t:188)
BB 0 (0x7fe9ddcb3818):
line: 188 (pc 0)
Instructions:
no_op
Successors: 1
@bdw
bdw / ListUtil.pm
Created August 27, 2019 10:01
Reimplementation of List::Util for running on perl 5.10
#!/usr/bin/env perl
package ListUtil;
# Reimplementation of List::Util for running on perl 5.10
use strict;
use warnings;
use Exporter 'import';
@ListUtil::EXPORT_OK = qw(pairgrep pairmap pairkeys pairvalues);
sub pairgrep(&@) {
my $code = shift;
@bdw
bdw / cmp_n.nqp
Created July 7, 2019 21:17
floating points nqp
#!/usr/bin/env nqp
if (0.125 < 0.126) {
nqp::say("OK");
} else {
nqp::die("NOT OK");
}
From b0cf91cf7bc32fc20f73f4abc463d952c86983a3 Mon Sep 17 00:00:00 2001
From: Bart Wiegmans <bartwiegmans@gmail.com>
Date: Fri, 17 May 2019 12:45:13 +0200
Subject: [PATCH] [Vector] Implement MVM_VECTOR_CONTAINS with memmem
This should be more flexible (arbitrary sized items) and hopefully
faster because memmem is fairly optimized. And allows the use as an
expression.
---
build/Makefile.in | 1 +

Linking Perl 6 Compiler and Programs

Description

Currently, starting a Perl 6 programs means loading a shell script that starts a MoarVM, that loads the rakudo compiler (as bytecode) and libraries (also bytecode), before loading the user script and compiling that. This adds significantly to the startup time of perl6

#!/usr/bin/env nqp
sub foo(int64 $x) {
my int16 $y := $x;
my int64 $z := $y;
return $z;
}
my int $i := 0;
while ($i++ < 100_000) {
@bdw
bdw / shift.nqp
Created October 6, 2018 19:32
shift test
#!/usr/bin/env nqp
sub shifter(int $x, int $y) {
nqp::abs_i(nqp::bitshiftl_i($x, $y));
}
my int $i := 0;
while ($i++ < 1_000_000) {
my $x := shifter(10,3);
if (shifter(10,3) != 80) {
@bdw
bdw / spesh-log.txt
Created October 5, 2018 09:04
INLINE_END ends up on prepargs
Specialization of 'repository-version' (cuid: 15072)
Before:
Spesh of 'repository-version' (cuid: 15072, file: SETTING::src/core/CompUnit/Repository/Installation.pm6:129)
BB 0 (0x7fffec65a388):
line: 129 (pc 0)
Instructions:
no_op
Successors: 1
@bdw
bdw / reciprocal.c
Last active August 19, 2018 08:12
minor benchmarks
#include <stdio.h>
/* this takes, excluding compilation, 0.23s on my machine.
* MoarVM is within a factor of three of that */
int main(int argc, char **argv) {
double x = 0;
int i;
for (i = 1; i < 50000000; i++)
x += 1.0/i;
printf("%f", x);
=================================================================
==31674==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 416 byte(s) in 2 object(s) allocated from:
#0 0x7fd9b5224e50 in calloc (/lib64/libasan.so.5+0xeee50)
#1 0x7fd9b40924c5 in MVM_calloc src/core/alloc.h:11
#2 0x7fd9b409de50 in MVM_spesh_graph_create src/spesh/graph.c:1214
#3 0x7fd9b40df1f9 in MVM_spesh_inline_try_get_graph_from_unspecialized src/spesh/inline.c:236
#4 0x7fd9b40cd1f3 in optimize_call src/spesh/optimize.c:1831